package com.kotlin.lib.coroutines

import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking

fun main() = runBlocking<Unit> {

    repeat(1000) {
        launch {
            delay(200)
            println(".$it")
        }
    }

    launch {
        doPrint(500, "launch execute done")
    }
    println("launch over")
    coroutineScope {//suspend method.
        launch {
            delay(1500)
            println("coroutineScope#launch execute")
        }
        delay(1000)
        println("coroutineScope execute done")
    }
    println("runBlocking over")
}

private suspend fun doPrint(delayTime: Long, message: String) {
    delay(delayTime)
    println(message)
}